package edu.jhu.cs.oose.scheduleit.dao;

import java.util.List;

import org.springframework.dao.DataIntegrityViolationException;

import edu.jhu.cs.oose.scheduleit.util.JoinStatus;
import edu.jhu.cs.oose.scheduleit.vo.Group;
import edu.jhu.cs.oose.scheduleit.vo.User;
/**
 * The DAO class for User VO object.
 * @author oosegroup2
 *
 */
public interface UserDao {
	/**
	 * Responsible for save the user object into the database
	 * @param user
	 * @throws DataIntegrityViolationException if the email of the user are duplicated, the exception would be throw out 
	 */
	public void save(User user) throws DataIntegrityViolationException;
	/**
	 * Get the user which has the same email and the same password
	 * @param email the email address of the user
	 * @param password the password of the user
	 * @return the user which has the same email and the same password
	 */
	public User get(String email, String password);
	/**
	 * Get the user which has the same email
	 * @param email the email address of the user
	 * @return the user which has the same email
	 */
	public User get(String email);
	
	/**
	 * Retrieve the groups satisfying given conditions
	 * @param user	The user who owns the objective groups
	 * @param status	The join status of objective groups
	 * @param offset	The offset of the first group in the list
	 * @param limit		The limit number of the objective groups
	 * @return	The groups satisfying given conditions
	 */
	public List<Group> getGroup(User user, JoinStatus status, int offset, int limit);
	
	/**
	 * Calculate how many groups of certain type, owned by a given user
	 * @param user	The user who owns the objective group
	 * @param status	The join status of the objective group
	 * @return	The number of how many groups satisfying the given conditions
	 */
	public int countGroup(User user, JoinStatus status);
	
	/**
	 * Add the user to the group according to JoinStatus
	 * @param user the user who wants to join the group
	 * @param group the group in which the user wants to join 
	 * @param status the join status for the user
	 */
	public void addGroup(User user, Group group, JoinStatus status);

	/**
	 * Delete the user from the group according to JoinStatus
	 * @param group the group which the user wants to quit 
	 * @param user user the user who wants to quit the group
	 * @param status the join status for the user
	 */
	public void deleteGroup(Group group, User user, JoinStatus status);

	
}
